package com.legoo.studaychineseonline.utils;

import android.widget.ImageView;


import com.legoo.studaychineseonline.R;

import org.xutils.image.ImageOptions;
import org.xutils.x;

/**
 * 作者：Jason_Jukes on 2018/10/17 0017 15:14
 * <p>
 * When I wrote this, only God and I understood what I was doing
 * Now, only God knows
 */

public class ImageUtil {


    //设置普通图片
    public void setImg(ImageView imageView, String url) {

        ImageOptions options = new ImageOptions.Builder()
                .setFadeIn(true)
                .setIgnoreGif(false)
                .setLoadingDrawableId(R.color.colorPrimary)
                .setFailureDrawableId(R.color.colorPrimary)
                .build();
        x.image().bind(imageView, url, options);

    }


    //设置圆形图片
    public void setCircleImg(ImageView imageView, String url) {

        ImageOptions options = new ImageOptions.Builder()
                .setFadeIn(true)      //淡入效果
                .setCircular(true)
                .setIgnoreGif(false)
                .setLoadingDrawableId(R.color.colorPrimary)
                .setFailureDrawableId(R.color.colorPrimary)
                .build();

        x.image().bind(imageView, url, options);

    }


    //设置圆角图片
    public void setRaduisImg(ImageView imageView, String url, int raduis) {

        ImageOptions options = new ImageOptions.Builder()
                .setFadeIn(true) //淡入效果
                .setRadius(raduis)
                .setIgnoreGif(false)
                .setLoadingDrawableId(R.color.colorPrimary)
                .setFailureDrawableId(R.color.colorPrimary)
                .build();

        x.image().bind(imageView, url, options);

    }


}
